//
//  ExpressView.swift
//  swiftProject
//
//  Created by ZhangSai on 2021/6/10.
//

import UIKit

protocol ExpressViewDelegate:class {
    func homeViewAcrionDelegate(actonType:HomeViewActonType)
}

class ExpressView: UIView {
    
    weak var delegate:ExpressViewDelegate?
    @IBOutlet weak var logisticsTitleLab: UILabel!
    @IBOutlet weak var messageLab: UILabel!
    @IBOutlet weak var scanmessageLab: UILabel!
    @IBOutlet weak var scanBtn: UIButton!
    @IBOutlet weak var bgView: UIView!

    override func awakeFromNib() {
        super.awakeFromNib()
        self.bgView.isUserInteractionEnabled = true
        let tapGR = UITapGestureRecognizer.init(target: self, action: #selector(scanAction))
        self.bgView.addGestureRecognizer(tapGR)
        
        self.bgView.layer.shadowColor = UIColor.init(red: 0, green: 0, blue: 0, alpha: 0.2).cgColor
        self.bgView.layer.shadowOpacity = 1
        self.bgView.layer.shadowOpacity = 1
        self.bgView.layer.shadowRadius = 2
        self.bgView.layer.cornerRadius = 5
        self.bgView.layer.shadowOffset = CGSize.init(width: 0, height: 1);//投影偏移
        
        NotificationCenter.default.addObserver(self, selector: #selector(setUI), name: NSNotification.Name(rawValue: "languageNotification"), object: nil)
        self.setUI()
    }
    
    @objc func setUI() {
        self.logisticsTitleLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.order_logistics_operation)
        self.scanBtn.setTitle(ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.order_Scan), for: .normal)
        self.messageLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.order_Scan_operate)
        self.scanmessageLab.text = ZslanguageTool.sharedLanguageTool().getIanguageWithKey(key: LanguageHeader.order_order_sateMsg)
    }
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        super.touchesBegan(touches, with: event)
        self.delegate?.homeViewAcrionDelegate(actonType: HomeViewActonType.Home_EndEditingType)
    }
    
    @IBAction func ScanBtnAction(_ sender: UIButton) {
        self.delegate?.homeViewAcrionDelegate(actonType: HomeViewActonType.Home_ScanDataType)
    }
    
    @objc func scanAction() {
        self.delegate?.homeViewAcrionDelegate(actonType: HomeViewActonType.Home_ScanDataType)
    }
    
}
